/**
 * Created with IntelliJ IDEA.
 * User: jiang.li
 * Date: 13-10-23
 * Time: 上午11:01
 * To change this template use File | Settings | File Templates.
 */

window.AllDocCrt = function ($rootScope, $scope) {

    //组装查询参数
    $scope.queryParams || ( $scope.queryParams = {});
    $scope.queryParams.pageSize = 15;

    //查询数据函数
    var loadData = function () {
        $.ajax({
            url: '/services/api/common/access_log/queryAll',
            type: "GET",
            data: $scope.queryParams,
            dataType: "json",
            success: function (data) {
                $scope.pageData = pageToObj(data);
                applyAngularScope($rootScope, $scope);
            }
        });
    }

    //查询时间
    $scope.search = function () {
        $scope.queryParams.word = $scope.word;
        $scope.queryTime = $("#timeFiled").val();
        $scope.queryParams.time = $scope.queryTime;
        $scope.queryParams.pageNo = 1;
        loadData();
    }

    //查询重置
    $scope.reset = function () {
        $scope.word = "";
        $scope.queryTime = "";
        $scope.queryParams.word = $scope.word;
        $scope.queryTime = $("#timeFiled").val();
        $scope.queryParams.time = $scope.queryTime;
        $scope.queryParams.pageNo = 1;
        loadData();
    }

    //分页
    $scope.goPage = function (pageNo, className) {
        if (className == 'disabled') {
            return;
        }
        $scope.queryParams.pageNo = pageNo;
        loadData();
    }

    //回车键事件
    $("#searchFiled").keydown(function (e) {
        var curKey = e.which;
        if (curKey == 13) {
            $scope.search();
            return false;
        }
    });

    //首次加载数据
    loadData();
}